#include "../global.h"

#include <QGridLayout>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    vtkWidgetCreate(manWidgetP, QVTKWidget);
    QWidget* manWidget = manWidgetP.data();

    QPointer<QGridLayout> layoutP(new QGridLayout(manWidget));
    QGridLayout* layout = layoutP.data();

    manWidget->setLayout(layout);

    vtkCreate(reader, vtkDICOMImageReader);
    reader->SetDataByteOrderToLittleEndian();
    reader->SetDirectoryName(path.toStdString().c_str());
    reader->Update();

    vtkCreate(rendererx, vtkRenderer);
    vtkWidgetCreate(widgetx, QVTKWidget);
    QVTKWidget* vtkWidgetx = widgetx.data();
    vtkCreate(imageViewerx, vtkImageViewer2);
    imageViewerx->SetInputConnection(reader->GetOutputPort());
    imageViewerx->UpdateDisplayExtent();
    imageViewerx->SetRenderWindow(vtkWidgetx->GetRenderWindow());
    imageViewerx->SetRenderer(rendererx);
    imageViewerx->SetupInteractor(vtkWidgetx->GetRenderWindow()->GetInteractor());
    imageViewerx->SetColorLevel(500);
    imageViewerx->SetColorWindow(2000);
    imageViewerx->SetSliceOrientationToXY();
    layout->addWidget(vtkWidgetx,0,0);
    vtkWidgetx->GetRenderWindow()->AddRenderer(rendererx);

    vtkCreate(renderery, vtkRenderer);
    vtkWidgetCreate(widgety, QVTKWidget);
    QVTKWidget* vtkWidgety = widgety.data();
    vtkCreate(imageViewery, vtkImageViewer2);
    imageViewery->SetInputConnection(reader->GetOutputPort());
    imageViewery->UpdateDisplayExtent();
    imageViewery->SetRenderWindow(vtkWidgety->GetRenderWindow());
    imageViewery->SetRenderer(renderery);
    imageViewery->SetupInteractor(vtkWidgety->GetRenderWindow()->GetInteractor());
    imageViewery->SetColorLevel(500);
    imageViewery->SetColorWindow(2000);
    imageViewery->SetSliceOrientationToXZ();
    layout->addWidget(vtkWidgety,0,1);
    vtkWidgety->GetRenderWindow()->AddRenderer(renderery);

    vtkCreate(rendererz, vtkRenderer);
    vtkWidgetCreate(widgetz, QVTKWidget);
    QVTKWidget* vtkWidgetz = widgetz.data();
    vtkCreate(imageViewerz, vtkImageViewer2);
    imageViewerz->SetInputConnection(reader->GetOutputPort());
    imageViewerz->UpdateDisplayExtent();
    imageViewerz->SetRenderWindow(vtkWidgetz->GetRenderWindow());
    imageViewerz->SetRenderer(rendererz);
    imageViewerz->SetupInteractor(vtkWidgetz->GetRenderWindow()->GetInteractor());
    imageViewerz->SetColorLevel(500);
    imageViewerz->SetColorWindow(2000);
    imageViewerz->SetSliceOrientationToYZ();
    layout->addWidget(vtkWidgetz,1,0);
    vtkWidgetz->GetRenderWindow()->AddRenderer(rendererz);

    manWidget->resize(WINDOW_WIDTH, WINDOW_HEIGHT);
    manWidget->show();


    return a.exec();
}
